package com.own.test_4_8;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.*;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/regist")

public class RegistServlet extends HttpServlet {
    @Override
    //用于处理Get请求（会显示输入内容）和Post请求
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //保证中文正常输出
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        //获取用户的请求
        String username = request.getParameter("username");
        String pwd = request.getParameter("pwd");
        String gander= request.getParameter("gender");

        //处理请求（完成业务逻辑功能）
        System.out.println(username);
        System.out.println(pwd);
        System.out.println(gander);

        //响应
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println(username + "regist sucessful");
        out.println("</body></html>");
        out.flush();
        out.close();


    }
}
